/* Page Transitions and Preloaders */
:root {
    --preloader-bg: #0f172a;
    --accent-color: #22c55e;
}

/* Page Transition Animation */
.page-fade-out {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-fade-in {
    opacity: 1;
    transform: translateY(0);
}

body {
    opacity: 0;
    transition: opacity 0.5s ease;
}

body.loaded {
    opacity: 1;
}

/* Preloader Container */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* استفاده از رنگ ثابت متناسب با تم در لحظه اول */
    background-color: var(--color-bg-main, #020617);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* Force light background immediately if theme is light */
[data-theme='light'] #preloader {
    background-color: #f8fafc !important;
}

[data-theme='dark'] #preloader {
    background-color: #020617 !important;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Equalizer Preloader */
.equalizer {
    display: flex;
    align-items: flex-end;
    height: 40px;
    gap: 4px;
}

.equalizer span {
    width: 6px;
    background: var(--color-primary);
    animation: equalizer 1s ease-in-out infinite;
    border-radius: 3px;
}

.equalizer span:nth-child(1) { height: 15px; animation-delay: -1.2s; }
.equalizer span:nth-child(2) { height: 25px; animation-delay: -1.1s; }
.equalizer span:nth-child(3) { height: 40px; animation-delay: -1.0s; }
.equalizer span:nth-child(4) { height: 30px; animation-delay: -0.9s; }
.equalizer span:nth-child(5) { height: 20px; animation-delay: -0.8s; }

@keyframes equalizer {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.4); }
}

/* Vinyl Preloader */
.vinyl-preloader {
    width: 100px;
    height: 100px;
    position: relative;
    display: none;
}

.record {
    width: 100%;
    height: 100%;
    background: #111;
    border-radius: 50%;
    border: 2px solid #333;
    position: relative;
    animation: rotate 2s linear infinite;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
}

.record::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    background: var(--color-primary);
    border-radius: 50%;
}

.record::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6%;
    height: 6%;
    background: var(--color-bg-main);
    border-radius: 50%;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Music Pulse */
.music-pulse {
    width: 60px;
    height: 60px;
    background: var(--color-primary);
    border-radius: 50%;
    display: none;
    position: relative;
    animation: pulse 1.5s ease-out infinite;
}

.music-pulse::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: inherit;
    border-radius: 50%;
    top: 0;
    left: 0;
    animation: pulse-ring 1.5s ease-out infinite;
    opacity: 0.6;
}

@keyframes pulse {
    0% { transform: scale(0.8); }
    50% { transform: scale(1); }
    100% { transform: scale(0.8); }
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}
